import React from "react";
import { shallowEqual } from "react-redux";
import { useAppDispatch, useAppSelector } from "../redux/hook";
import { change, back } from "../redux/slice";

export const BPage = () => {
  console.log("B渲染了");

  const { text } = useAppSelector((state: any) => ({ ...state.state }), shallowEqual);
  const dispatch = useAppDispatch();
  return (
    <div>
      <h1>我是Bpage</h1>
      <h2>我是text:{text}</h2>
      <button
        onClick={() => {
          dispatch(change());
        }}
      >
        改变
      </button>
      <button
        onClick={() => {
          dispatch(back());
        }}
      >
        还原
      </button>
    </div>
  );
};
